{extend name="public/base" /}
{block name="button"}
<button data-target-submit class='layui-btn layui-btn-sm'>保存数据</button>
<button data-target-backup class="layui-btn layui-btn-sm layui-btn-danger">取消编辑</button>
{/block}
{block name="content"}
<form method="post" class="layui-form layui-card" id="ArticleTable" onsubmit="return false">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label">文章标题</label>
            <div class="layui-input-block">
                <input name="title" value="{$vo.title|default=''}" required vali-name="标题名称" placeholder="请输入文章标题" class="layui-input" type="text">
                <p class="help-block"><b>必填</b>，请填写文章标题</p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">所属分类</label>
            <div class="layui-input-block">
                {foreach $categoryList as $val}
                <input type="checkbox" name="category_id[]" title="{$val.name}" value="{$val.id}" {if !empty($val.checked)} checked {/if}/>
                {/foreach}
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">缩略图</label>
            <div class="layui-input-block">
                <input type="hidden" data-accept-mime="image/*"  data-file-type="1" name="thumb" value="{$vo.thumb|default=''}" data-cut-width="600" data-cut-height="600" data-max-width="600" data-max-height="600">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="number" name="sort" required vali-name="排序" placeholder="请输入排序" value="{$vo.sort|default='50'}" class="layui-input">
                <p class="help-block">
                    <b>必须是数字排序越小越靠前</b>
                </p>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入用户描述" class="layui-textarea" name="desc">{$vo.desc|default=""}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <script id="container" type="text/plain" style="width:100%;height:500px;">{notempty name="vo.content"}{$vo.content|raw}{/notempty}</script>
            </div>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
     <input type='hidden' value='{$vo.id|default=0}' name='id'>

    <div class="layui-form-item text-center">
        <button data-target-submit class="layui-btn">保存数据</button>
        <button data-target-backup class="layui-btn layui-btn-danger" type="button">取消编辑</button>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    window.UEDITOR_HOME_URL = "/static/admin/plugs/ueditor/";
    require(['baidueditor',"jquery"],function (UE,$) {
        var editor = UE.getEditor('container');
        $.menu.highlight_subnav("{:url('index')}")
        $('[name=thumb]').uploadOneImage();
        $('#ArticleTable').vali(function (form) {
            Object.assign(form, {content: UE.getEditor('container').getContent()})
            delete form.editorValue
            $.form.load('{:url()}', form, 'post');
        });
    });
</script>
{/block}
